package mvc.selix;

import java.awt.Dimension;

import gui.Block;
import gui.CheckboxPanel;
import gui.SliderPanel;

import javax.swing.BoxLayout;
import javax.swing.JPanel;

import mvc.ControllerMouse3D;

import org.geom.render.IRenderer;

public class SelixBlock extends Block {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	
	SelixModel curve;

	public SelixBlock(String title, SelixModel selixModel) {
		super(title);
		
		this.curve = selixModel;
		// 1 view3D, e il pannello di controllo
		
		initSwing(selixModel);
	}

	private void initSwing(SelixModel selix) {
		SelixView3D view3D;
		
		view3D = new SelixView3D(selix, new Dimension(730,700));
		selix.addView((IRenderer) view3D);
		ControllerMouse3D controller = new ControllerMouse3D(view3D);
		view3D.addMouseKeybController(controller);
		addView(view3D);
	}
	
	@Override
	protected void initControls() {
		super.initControls();
		
		JPanel p = new JPanel();
		p.setLayout(new BoxLayout(p, BoxLayout.Y_AXIS));
		
		SelixPanelController controller = new SelixPanelController( curve);
		
		CheckboxPanel c = new CheckboxPanel("Trunk Visibility",controller, "TrunkVisibility");
		controller.setTrunkVisibility(true);
		p.add(c);
		
		SliderPanel s = new SliderPanel("Set radius", 0, 100, 5, controller, "R");
		controller.setR(5, false);
		p.add(s);
		
		s = new SliderPanel("Set sprial number", 0, 100, 20, controller, "U");
		controller.setU(20, false);
		p.add(s);
		
		s = new SliderPanel("Set lenght", 0, 100, 0, controller, "K");
		controller.setK(0, false);
		p.add(s);
		
		s = new SliderPanel("Set sampling rate", 4, 3000, 500, controller, "Sampling");
		controller.setSampling(500, false);
		p.add(s);
		
		controlWindow.add(p);
		controlWindow.setLocation(1000, 300);
	}

}
